<div class="paging">
    <?php
    echo $this->Paginator->options(array('update' => '#content', 'evalScripts' => false));
    echo $this->Paginator->prev('< ' . __('Anterior'), array(), null, array('class' => 'prev disabled'));
    echo $this->Paginator->numbers(array('separator' => ''));
    echo $this->Paginator->next(__('Siguiente') . ' >', array(), null, array('class' => 'next disabled'));
    ?>
</div>
<br>
<table>
    <tbody>
        <tr>
            <td colspan="2">
                <?php
                echo $paginator->counter(array(
                    'format' => 'Página %page% de %pages%, Mostrando %current% registros de %count% totales, empezando en %start%, terminando en %end%'
                        )
                );
                ?> 
            </td>
        </tr>
    </tbody>
</table>
<table id="tabla">
    <thead>
        <tr>
            <th><?php echo $this->Paginator->sort('Nombre del banco', 'BankAccount.nombre_banco'); ?></th>
            <th><?php echo $this->Paginator->sort('Valor', 'BankAccount.valor'); ?></th>
            <th><?php echo $this->Paginator->sort('Nombre del titular', 'BankAccount.nombre_titular'); ?></th>
            <th><?php echo $this->Paginator->sort('Documento titular', 'BankAccount.documento_titular'); ?></th>
            <th><?php echo $this->Paginator->sort('Tipo titular', 'BankAccount.tipo_titular'); ?></th>
            <th colspan ="3"></th>
        </tr>
    </thead>
    <tbody>
        <?php
        $sumaDesembolsos = 0;
        foreach ($BankAccounts as $BankAccount):
            ?>
            <tr>
                <td><?php echo $BankAccount['BankAccount']['nombre_banco']; ?></td>
                <td><?php echo '$ ' . number_format($BankAccount['BankAccount']['valor'], 2, ',', '.'); ?></td>
                <td><?php echo $BankAccount['BankAccount']['nombre_titular']; ?></td>
                <td><?php echo $BankAccount['BankAccount']['documento_titular']; ?></td>
                <td><?php
        echo $BankAccount['BankAccount']['tipo_titular'];
        $sumaDesembolsos += $BankAccount['BankAccount']['valor'];
            ?></td>

                <td><?php echo $this->Ajax->link('Editar', array('controller' => 'BankAccounts', 'action' => 'editProperties', $BankAccount["BankAccount"]["id"], $expense_property_id), array('class' => 'actions', 'update' => 'content', 'indicator' => 'loading')); ?></td>
                <td><?php echo $this->Ajax->link('Eliminar', array('controller' => 'BankAccounts', 'action' => 'delete', $BankAccount["BankAccount"]["id"], $expense_property_id), array('class' => 'actions', 'update' => 'content', 'indicator' => 'loading')); ?></td>

                <td>
                    <?php if (file_exists($BankAccount['BankAccount']['adjunto'] . ".pdf")): ?>
                        <a href="<?php echo $BankAccount['BankAccount']['adjunto'] . ".pdf" ?>" target="blank" class="actions" >Adjunto</a>
                    <?php endif; ?>
                </td>

            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php echo $this->Js->writeBuffer(); ?>
<br>

<?php
$error = false;
if ($valor_subsidio_predios != $sumaDesembolsos) {
    $error = true;
}
?>

<table border="1" id="tabla">
    <thead>
        <tr>
            <th>Valor subsidio total</th>
            <th>Sumatoria de valores a desembolsar</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td <?php echo ($error ? "style='background-color: #F79F81;'" : "style='background-color: #81F7D8;'") ?>>
                <?php echo '$ ' . number_format($valor_subsidio_predios, 2, ',', '.') ?>
            </td>
            <td <?php echo ($error ? "style='background-color: #F79F81;'" : "style='background-color: #81F7D8;'") ?>>
                <?php echo '$ ' . number_format($sumaDesembolsos, 2, ',', '.') ?>
            </td>
        </tr>
    </tbody>
</table>
<br><br><br>


<?php echo $this->Ajax->link('Adicionar', array('controller' => 'BankAccounts', 'action' => 'addProperties', $expense_property_id), array('update' => 'content', 'indicator' => 'loading', 'class' => 'actions')); ?>

<br><br>
<?php echo $ajax->link($html->image('regresar.gif', array('width' => '30', 'heigth' => '30', 'alt' => 'Regresar', 'title' => 'regresar')), array('controller' => 'expense_properties', 'action' => 'index'), array('update' => 'content', 'indicator' => 'loading', 'escape' => false)); ?>